/*
 * @Author: ipk518 121206530@qq.com
 * @Date: 2023-12-24 18:53:10
 * @LastEditors: ipk518 121206530@qq.com
 * @LastEditTime: 2024-09-26 16:31:43
 * @FilePath: /RemoteUpdates/inc/Conf.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

#pragma once
#include <string>
#include "Result.h"
#include <limits>

#define DEV_TYPE_UNKNOWN                                                                                                                                            std::numeric_limits<uint16_t>::max()
#define DEV_TYPE_SXD                                                                                                                                                 1

/**************************************************************************/
#define CURRENT_DEVICE "SYD"

#define TCP_PORT    6152
#define TCP_HEADER_SIZE 10

#define UDP_PORT    6153
#define UDP_HEADER_SIZE 10
#define UDP_CHUNK_SIZE  1280
#define UDP_CONFIRM_MAGIC_SIZE  0x67899876

#define RAMFS_MOUNT_POINT "/tmp/.Skillwon"
#define RAMFS_MAX_SIZE (50*1024*1024)
/**************************************************************************/

// namespace begin.
namespace Conf 
{


struct ConfDotTcp final 
{
    uint16_t port;
    size_t headerSize;
};

struct ConfDotUdp final 
{
    uint16_t port;
    size_t headerSize;
    size_t chunkSize;
    uint32_t confirmMagic;
};

struct ConfDotRamfs final 
{
    std::string mountPoint;
    size_t maxSize;
    std::string description;
};

struct ConfItem final 
{
    std::string type;
    bool debug;
    std::string shell;
    uint16_t typeValue;
    ConfDotTcp tcp;
    ConfDotUdp udp;
    ConfDotRamfs ramfs;
};

ConfItem *currentConf();
Result loadConf(const std::string &path);
uint16_t convertDevType2Integer(const std::string &typeStr);


}  // namespace end.
